package tests;

import common.Utils;
import org.openqa.selenium.By;

public class RegisterPage extends Utils {
    public static String url = "http://127.0.0.1:58080/sign-up.html";
    public RegisterPage() {
        super(url);
    }

    /**
     * allNoWrite
     * 注册信息全部都不填写
     */
    public void allNoWrite() {
        driver.findElement(By.cssSelector("#submit")).click();
        driver.findElement(By.cssSelector("#signUpForm > div > h2"));
        driver.navigate().refresh();
    }

    /**
     * partWrite1
     * 用户填写，其余都不填写
     */
    public void partWrite1() {
        driver.findElement(By.cssSelector("#username")).sendKeys("123");
        driver.findElement(By.cssSelector("#submit")).click();
        driver.findElement(By.cssSelector("#signUpForm > div > div:nth-child(3) > div"));
        driver.navigate().refresh();
    }

    /**
     * partWrite2
     * 昵称和确认密码填写，其余不填写
     */
    public void partWrite2() {
        driver.findElement(By.cssSelector("#nickname")).sendKeys("123");
        driver.findElement(By.cssSelector("#passwordRepeat")).sendKeys("123456");
        driver.findElement(By.cssSelector("#submit")).click();
        driver.findElement(By.cssSelector("#signUpForm > div > div:nth-child(2) > div"));
        driver.navigate().refresh();
    }

    /**
     * partWrite3
     * 密码和同意勾选，其余都不填写
     */
    public void partWrite3() {
        driver.findElement(By.cssSelector("#password")).sendKeys("123456");
        driver.findElement(By.cssSelector("#policy")).click();
        driver.findElement(By.cssSelector("#submit")).click();
        driver.findElement(By.cssSelector("#signUpForm > div > div:nth-child(2) > div"));
        driver.navigate().refresh();
    }

    /**
     * partWrite4
     * 用户、昵称、密码填写，其余都不填写
     */
    public void partWrite4() {
        driver.findElement(By.cssSelector("#username")).sendKeys("123");
        driver.findElement(By.cssSelector("#nickname")).sendKeys("123");
        driver.findElement(By.cssSelector("#password")).sendKeys("123456");
        driver.findElement(By.cssSelector("#submit")).click();
        driver.findElement(By.cssSelector("#signUpForm > div > div:nth-child(5) > div > div"));
        driver.navigate().refresh();
    }

    /**
     * partWrite5
     * 确认密码填写、同意勾选，其余都不填写
     */
    public void partWrite5() {
        driver.findElement(By.cssSelector("#passwordRepeat")).sendKeys("123456");
        driver.findElement(By.cssSelector("#policy")).click();
        driver.findElement(By.cssSelector("#submit")).click();
        driver.findElement(By.cssSelector("#signUpForm > div > div:nth-child(4) > div > div"));
        driver.navigate().refresh();
    }

    /**
     * registerSucceed
     * 全部填写，注册成功
     */
    public void registerSucceed() {
        driver.findElement(By.cssSelector("#username")).sendKeys(userName);
        driver.findElement(By.cssSelector("#nickname")).sendKeys("111");
        driver.findElement(By.cssSelector("#password")).sendKeys("123456");
        driver.findElement(By.cssSelector("#passwordRepeat")).sendKeys("123456");
        driver.findElement(By.cssSelector("#policy")).click();
        driver.findElement(By.cssSelector("#submit")).click();
        driver.findElement(By.cssSelector("body > div > div > div > div:nth-child(1) > div > div.card.card-md > div > h2"));
    }
}
